<%@ page language="java" import="com.school.movie.common.utils.ContextUtils" pageEncoding="UTF-8" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <base href="<%=basePath%>">

    <title>个人设定</title>
    <jsp:include page="/IncludeJS.jsp"></jsp:include>
    <script type="text/javascript">
        $(function () {
            if ("${msg}" != null && "${msg}" != "") {
                if ("${msg}" == "pwdsucc") {
                    modifypwd();
                    alert("个人密码修改成功，请重新登陆！");
                } else if ("${msg}" == "pwderror") {
                    modifypwd();
                    alert("旧密码错误！");
                } else {
                    alert("${msg}");
                }
            }
            var h = document.body.clientHeight;
            $('#maintable').height(h);
        });

        function info() {
            //$("#modifyInfo").style.display="block";
            //$("#modifyPwd").style.display="none";
            $("#modifyInfo").show();
            $("#modifyPwd").hide();
            //$("#trinfo").css('background-color','#cfd4e6');
            //$("#trpwd").css('background-color','#ffffff');
            $("#trinfo").html("<font size='2'><b>个人资料</b></font>");
            $("#trpwd").html("<font size='2'>修改密码</font>");
        }

        function modifypwd() {
            $("#modifyInfo").hide();
            $("#modifyPwd").show();
            $("#trinfo").html("<font size='2'>个人资料</font>");
            $("#trpwd").html("<font size='2'><b>修改密码</b></font>");
        }

        function check() {
            if ($("#oldpwd").val() == "") {
                alert("请输入旧密码");
                $("#oldpwd").focus();
                return false;
            }
            if ($("#password").val() == "") {
                alert("请输入新密码");
                $("#password").focus();
                return false;
            }
            if ($("#password").val() != $("#cfgpwd").val()) {
                alert("新密码与确认密码不符");
                $("#cfgpwd").focus();
                return false;
            }
            return true;
        }

    </script>
</head>

<body>
<table width="980" id="maintable">
    <tr>
        <td valign="top" width="200">
            <div style="border:1px solid #6593CF;width:100%;height:100%">
                <table width="100%" height="65">
                    <tr height="5">
                        <td>&nbsp;</td>
                    </tr>
                    <tr height="30">
                        <td style="padding-left:10px "><a href="javascript:void(0);" onclick="info();" id="trinfo"
                                                          onmousemove="info();"><font size="2">个人资料</font></a></td>
                    </tr>
                    <tr height="30">
                        <td style="padding-left:10px "><a href="javascript:void(0);" onclick="modifypwd();" id="trpwd"
                                                          onmouseout="modifypwd();"><font size="2">修改密码</font></td>
                    </tr>
                </table>
            </div>

        </td>
        <td style="vertical-align: top;">
            <div data-options="closable:false,cache:false" style="padding:0px;height:100%;display:none;" id="modifyPwd">
                <form method="post" id="saveForm" action="${pageContext.request.contextPath }/updatePwd"
                      onsubmit="return check();">
                    <input type="hidden" name="managerId" id="id"
                           value="<%=ContextUtils.getManagerInfo().getManagerId()%>"/>
                    <table height="180">
                        <tr>
                            <td colspan="2" height="5">&nbsp;</td>
                        </tr>
                        <tr>
                            <td width="90" align="right">旧密码</td>
                            <td><input type="password" name="oldpwd" id="oldpwd" style="width:200px"/></td>
                        </tr>
                        <tr>
                            <td width="90" align="right">新密码</td>
                            <td><input type="password" name="managerPassword" id="password" style="width:200px"/></td>
                        </tr>
                        <tr>
                            <td width="90" align="right">确认新密码</td>
                            <td><input type="password" name="cfgpwd" id="cfgpwd" style="width:200px"/></td>
                        </tr>
                        <tr>
                            <td>&nbsp;</td>
                            <td align="center">
                                <input type="submit" value="保 存"></input>
                                <input type="reset" value="放 弃"></input>
                            </td>
                        </tr>
                    </table>
                </form>
            </div>
            <div data-options="closable:false,cache:false" style="padding:0px;height:100%;display:block;"
                 id="modifyInfo">
                <form method="post" id="saveForm" action="${pageContext.request.contextPath }/updateInfo">
                    <input type="hidden" name="managerId" id="id"
                           value="<%=ContextUtils.getManagerInfo().getManagerId()%>"/>
                    <table height="180">
                        <tr>
                            <td colspan="2" height="5">&nbsp;</td>
                        </tr>
                        <tr>
                            <td width="90" align="right">用户名</td>
                            <td><input type="text" name="managerAccount" id="managerAccount" disabled="disabled"
                                       value="<%=ContextUtils.getManagerInfo().getManagerAccount()%>"
                                       style="width:200px"/>
                            </td>
                        </tr>
                        <tr>
                            <td width="90" align="right">管理员姓名</td>
                            <td><input type="text" name="managerName" id="managerName"
                                       value="<%=ContextUtils.getManagerInfo().getManagerName()%>" style="width:200px"/>
                            </td>
                        </tr>
                        <tr>
                            <td width="90" align="right">性别</td>
                            <td>
                                <select name="sex" id="sex" style="width:200px">
                                    <c:if test="%{#request.manager.sex==0}">
                                        <option value="0">男</option>
                                        <option value="1" selected="selected">女</option>
                                    </c:if>
                                    <c:else>
                                        <option value="0" selected="selected">男</option>
                                        <option value="1">女</option>
                                    </c:else>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td width="90" align="right">联系方式</td>
                            <td><input type="text" name="contact" id="contact"
                                       value="<%=ContextUtils.getManagerInfo().getContact()%>" style="width:200px"/>
                            </td>
                        </tr>
                        <tr>
                            <td>&nbsp;</td>
                            <td align="center">
                                <input type="submit" value="保 存"></input>
                                <input type="reset" value="放 弃"></input>
                            </td>
                        </tr>
                    </table>
                </form>
            </div>
        </td>
    </tr>
</table>
</body>
</html>
